
#ifndef _IFONTFAMILY_H_
#define _IFONTFAMILY_H_

#include <BImage>
#include <BGlyph>

#include <ft2build.h>
#include <freetype/freetype.h>
#include <freetype/ftglyph.h>
#include <freetype/ftbitmap.h>
#include <freetype/ftsizes.h>

namespace BWE
{
	class CodeInfo
	{
	public:
		CodeInfo()
		{
			left = 0;
			top = 0;
			advance = 0;
		}
		CodeInfo(const CodeInfo& other)
		{
			left = other.left;
			top = other.top;
			advance = other.advance;
			glyph = other.glyph;
			bitmap = other.bitmap;
		}
		~CodeInfo()
		{

		}

		int				left;
		int				top;
		int				advance;
		BGlyphHolder	glyph;
		BImageHolder	bitmap;
	};

	class IFontFamily : public BObject
	{
	public:
		IFontFamily(const BString& fileName);
		~IFontFamily();

		bool open();
		bool close();

		bool changeEncoding(Encoding encoding);

		bool image(BCode code, const BSize& size, CodeInfo& info);
		BGlyph* glyph(BCode code, CodeInfo& info);

	public:
		BString				fileName;
		FT_Library			library;
		FT_Face				face;
		FT_Error			error;
		BArray<Encoding>	encodingList;
	};
	typedef BHolder<IFontFamily> FontFamilyHolder;
}

#endif